package comparison.sort.algorithm;

public class SelectionSort extends Sort {
	public SelectionSort(int size){
		super(size);
	}
	public SelectionSort(long[] data){
		super(data);
	}
	public void run(int left, int right){
		int smallest;
		SequenceNumText sequenceNumText = new SequenceNumText();
		String lineLogTemp="";
		int j=1;//log step
		for (int i=left;i<=right;i++){
			logSort += "\n"+sequenceNumText.getNumText(j++)+"\n"; //log step level 1
			lineLogTemp=stringData(); //log step level 2
			smallest =i;
			for (int index =i+1;index<=right;index++)
				if (data[index]<data[smallest])
					smallest=index;
			String logSwap="";
			logSwap = " Swap since "+data[smallest]+" is min of array";
			swap(i,smallest);
			lineLogTemp +=stringData()+logSwap+"\n";
			logSort +=lineLogTemp;
		}
	}
}
